<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        console.log('----筛选添加------');
        //筛选添加元素 push()
        var a = [100, 200, 300, 400, 500, 600, 700]
        var b = [];
        var c = [];
        for (var i = 0; i <= a.length; i++) {
            if (a[i] >= 300) {
                // b[b.length]=a[i];
                b.push(a[i]);
            }
        }
        console.log(b);


        console.log('----利用indexOf()去重------');

        var index = function (arr) {
            var ind = [];
            for (var i = 0; i < arr.length; i++) {
                if (ind.indexOf(arr[i]) === -1) {//新数组没有就返回-1然后添加，
                    ind.push(arr[i]);//去重添加到新数组
                }  
            }return ind;
        }
        var dom = index(['胡歌', '彭于晏', '胡歌', '胡歌', '彭于晏', '赵玉真', '赵玉真'])
        console.log(dom);



    </script>
</body>

</html>